<!DOCTYPE html>
<html>

{include file='public/header'}

<body>
    <div class="x-nav">
        <span class="layui-breadcrumb">
            <a href="javascript:void(0)">首页</a>
            <a href="javascript:void(0)">账号管理</a>
            <a><cite>公司管理</cite></a>
        </span>
        <a class="layui-btn layui-btn-small" id="reload" title="刷新">
            <i class="layui-icon" style="line-height:30px"><i class="iconfont">&#xe6aa;</i></i>
        </a>
    </div>
    <div class="x-body">
        <div class="layui-row">
            <form class="layui-form">
                <div class="layui-inline">
                    <label class="layui-form-label w-auto">公司名称：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="name" placeholder="请输入公司名称" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <button class="layui-btn" style="margin-left: 10px;" lay-submit lay-filter="searchList">搜索</button>
                <button type="reset" id="resetList" class="layui-btn layui-btn-primary">重置</button>
            </form>
        </div>
        <table id="company" lay-filter="company"></table>
    </div>
    <script type="text/html" id="toolbarDemo">
        <div class="layui-btn-container">
            <button class="layui-btn layui-btn-sm" lay-event="add">添加公司</button>
        </div>
    </script>
    <script type="text/html" id="tbBar">
        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
    </script>
    <script>
        let params = {
            elem: '#company'
            , toolbar: '#toolbarDemo'
            , url: '{:url("admin/company/list")}' //数据接口
            , id: 'company'
            , page:true
            , limit:15
            , cols: [[ //表头
                { field: 'id', title: 'ID', width: 80, sort: true,align:'center' }
                , { field: 'name', title: '公司名称',width:250 ,align:'center' }
                , { field: 'contacts', title: '联系人',align:'center' }
                , { field: 'contact_number', title: '联系电话', width: 120,align:'center' }
                , { field: 'is_distributor', title: '是否分销商',width: 100,align:'center', templet: function (d) {
                        return d.is_distributor == 1 ? '是' : '否'
                    }
                }
                , { field: 'payment_method', align:'center', width: 125, title: '收款方式', templet: function (d) {
                        return d.payment_method == 1 ? '银行卡(对公)' : d.payment_method == 2 ? '银行卡(对私)' : ''
                    }
                }
                , { field: 'payee', align:'center', title: '收款人', width: 240, align:'center'}
                , { field: 'collection_account', align:'center', title: '收款账号', width: 190, align:'center'}
                , { field: 'bank_name', align:'center', title: '开户行', align:'center', width: 240}
                , { field: 'tax_rate', align:'center', title: '增值税率', align:'center', width: 100}
                , { toolbar: '#tbBar', title: '操作', width: 80,align:'center' }
            ]]
        }
        tableList(params)

        layui.use('table', function () {
            var table = layui.table;
            table.on('toolbar(company)', function (obj) {
                var event = obj.event;
                if (event === 'add') {
                    x_admin_show('添加公司', './info.html', 650, 700);
                }
            });
            table.on('tool(company)', function (obj) {
                var event = obj.event;
                if (event === 'edit') {
                    x_admin_show('编辑公司', `./info.html?company_id=${obj.data.company_id}&id=${obj.data.id}`, 650, 700);
                }
            });

        });


    </script>
</body>

</html>